/*
 *
 * 名称：支十二
 * 功能：十二地支、命的状态状态、地支对等逻辑
 * 作者：清河张
 * 时间：2025.05.12
 *
 */

#ifndef ZHI12_H
#define ZHI12_H
#include "zhouqi.h"
#include "wuxing.h"
#include "yy.h"
#include "jieqi.h"
#include "gan10.h"

//命三种长生态
class MIN_T : public CT
{
public:
    enum EMIN
    {
        ZHSH,//长生，四驿马
        DIWANG,//帝旺，四桃花
        RUMU,//入墓，四墓库
    };
    //默认构造函数
    MIN_T();
    //全参数构造函数，默认属性配置
    MIN_T(int,const char*);

private:

};

typedef ZHOUQI<MIN_T,3> MIN3;



class ZHI_T : public CT
{
public:
    enum EZHI
    {
        ZIII,    CHOU,    YINN,
        MAO3,    CHEN,    SII4,
        WUU3,    WEI4,    SHEN,
        YOUU,    XUUU,    HAII,
        Z___ = INVALIDID
    };
    //默认构造函数
    ZHI_T();
    //全参数构造函数，默认属性配置
    ZHI_T(int id, int xing, int cg1, int cg2, int cg3,
          const char* name, const char* jingluo);

    //活跃经络
    const char* jingluo() const;
    //阴阳
    YY yy() const;
    //藏干
    void cg(GAN10 *g1 = nullptr, GAN10 *g2 = nullptr, GAN10 *g3 = nullptr) const;//藏干

    int xing() const;//相刑
private:
    struct
    {
        int _xing:6;//相刑
        int _cg1:6;//藏干本气
        int _cg2:6;//藏干中气
        int _cg3:6;//藏干余气
        int _resv:8;
    };
private:

    const char* _jingluo;
};

class ZHI12 : public ZHOUQI<ZHI_T,12>
{
public:
    //默认构造函数
    ZHI12();
    //使用父类初始化
    ZHI12(const ZHOUQI<ZHI_T,12>& );
    //初始化到指定对象
    ZHI12(int);
    //24节转为地支
    static ZHI12 JIE24(int j);

    //运算
    ZHI12& operator =(const ZHOUQI<ZHI_T,12>& zt);
    ZHI12& operator =(int id);

    //对应8宫序号，子为0
    int order8() const;
    int j1() const;//前截，比如子时23
    int j2() const;//后截，比如子时1
    WUXING5 wx5() const;//五行
    WUXING5 he6(ZHI12* z = nullptr) const;//六合
    WUXING5 he3(ZHI12* z1 = nullptr, ZHI12* z2 = nullptr) const;//三合
    WUXING5 hui3(ZHI12* z1 = nullptr, ZHI12* z2 = nullptr) const;//三会
    ZHI12 xing() const;//刑
    ZHI12 chong() const;//相冲
    ZHI12 hai() const;//相害

    ZHI12 taohua(ZHI12* z1 = nullptr, ZHI12* z2 = nullptr) const;//三桃花
    MIN3 min(ZHI12* z1 = nullptr, ZHI12* z2 = nullptr, ZHI12* z3 = nullptr) const;//同命
    ZHI12 maxing(ZHI12* z1 = nullptr, ZHI12* z2 = nullptr) const;//马星
};



struct ZHI12X2//双地支
{
    const int _z1, _z2;
    //初始化
    ZHI12X2(int z1, int z2);
    //名称
    const char* name() const;
    //地支一
    ZHI12 z1() const;
    //地支二
    ZHI12 z2() const;
private:
    //合并名
    char _name[32];
};

#endif // ZHI12_H
